package com.elong.businesstravel.modules.home.baseactivity;

import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;

import com.android.support.jhf.handlerui.HandlerPostUI;
import com.android.support.jhf.handlerui.HandlerToastUI;
import com.android.support.jhf.network.NetworkClient;
import com.android.support.jhf.network.loopj.android.http.ResponseHandlerInterface;
import com.android.support.jhf.utils.DateUtils;
import com.elong.businesstravel.R;
import com.elong.businesstravel.base.activity.BaseActivity;
import com.elong.businesstravel.base.dialog.CustomAlertDialog;
import com.elong.businesstravel.entitys.HotelPrice.GuaranteeRuleInfo;
import com.elong.businesstravel.entitys.SubmitOrderParam;
import com.elong.businesstravel.modules.orders.OrdersActivity;
import com.elong.businesstravel.protocol.order.CreateOrderRequest;
import com.elong.businesstravel.protocol.order.CreateOrderResponse;

/**
 * 用于提交订单、担保、付款的基类
 * 
 * @author lenovo
 * 
 */
public class BaseSubmitOrderActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

	}

	private void createOrders(SubmitOrderParam submitOrderParam) {

		NetworkClient.getNetworkClient().PostRequest(
				new CreateOrderRequest(mContext, 
						submitOrderParam.hotelid,
						submitOrderParam.roomid, 
						submitOrderParam.rpid,
						submitOrderParam.hotelname, 
						submitOrderParam.roomname,
						submitOrderParam.ratename, 
						submitOrderParam.starttime,
						submitOrderParam.endtime, 
						submitOrderParam.roomnum,
						submitOrderParam.customertype,
						submitOrderParam.paymenttype,
						submitOrderParam.totalprice,
						submitOrderParam.startdate, 
						submitOrderParam.enddate,
						submitOrderParam.earlyarrival,
						submitOrderParam.latestarrival,
						submitOrderParam.customer, 
						submitOrderParam.mobile,
						submitOrderParam.needcreditcard,
						submitOrderParam.crednum, 
						submitOrderParam.cvv,
						submitOrderParam.expyear, 
						submitOrderParam.expmonth,
						submitOrderParam.holdername, 
						submitOrderParam.idtype,
						submitOrderParam.idno, 
						submitOrderParam.needinvoice,
						submitOrderParam.invoicetitle,
						submitOrderParam.invoicetype,
						submitOrderParam.province, 
						submitOrderParam.city,
						submitOrderParam.area, 
						submitOrderParam.invoiceaddress,
						submitOrderParam.invoicename,
						submitOrderParam.invoicemobile,
						submitOrderParam.userscore, 
						submitOrderParam.bouns,
						submitOrderParam.totalbouns,
						submitOrderParam.paymentmothd,
						submitOrderParam.paymentmothds,
						submitOrderParam.guaranteeType,
						submitOrderParam.ticketid,
						submitOrderParam.ticketcash),
				new CreateOrderResponse() {
					@Override
					public void onResponse(
							ResponseHandlerInterface responseHandlerInterface) {
						if (1 == status) {
							HandlerPostUI.getHandlerPostUI(new Runnable() {

								@Override
								public void run() {
									showDialog();
								}
							});
						} else if (0 == status) {
							HandlerToastUI.getHandlerToastUI(mContext,
									resultTextString);
						}
					}
				});

	}

	private void showDialog() {
		CustomAlertDialog customAlertDialog = new CustomAlertDialog(mContext,
				R.style.CustomAlertDialog);
		customAlertDialog.setMessage("提交成功");
		customAlertDialog.setLeftButton("查看订单", new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Intent intent = new Intent(mContext, OrdersActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			}
		});
		customAlertDialog.setCancelable(false);
		customAlertDialog.setCanceledOnTouchOutside(false);
		customAlertDialog.setRightButtonGone();
		customAlertDialog.show();
	}

}
